#include <stdio.h>
int main()
{
	int arr[101] = { 0 };
	int i = 0;
	while (scanf("%d", arr + i++) == 1 && arr[i - 1] != 0);
	i -= 2;
	while (i >= 0)printf("%d ", arr[i--]);
	return 0;
}